package com.cloud.system.api.web;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cloud.system.api.bean.SysDictForm;
import com.cloud.system.api.entity.SysDict;
import com.cloud.system.api.service.SysDictService;
import com.cloud.system.common.exception.BizException;
import com.cloud.system.common.result.Quokka;

@RestController
@RequestMapping("system/api/sysdict")
public class SysDictController {

	@Autowired
	private SysDictService sysDictService;

	@RequestMapping("list")
	public Quokka list() {
		return new Quokka(true, sysDictService.list());
	}

	@RequestMapping("saveupdate")
	public Quokka saveUpdate(@RequestBody SysDictForm form) {
		SysDictForm f = null;
		try {
			f = sysDictService.saveUpdateDict(form);
		} catch (BizException e) {
			return new Quokka(false, e.getMessage());
		}
		return new Quokka(true, f);
	}

	@RequestMapping("loaddetail")
	public Quokka loadDictDetails(int id) {
		return new Quokka(true, sysDictService.loadDictDetail(id));
	}

	@RequestMapping("delete")
	public Quokka delete(@RequestBody SysDict dict) {
		return new Quokka(true, sysDictService.deleteSysDict(dict));
	}
	
}
